﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Windows.Forms.DataVisualization.Charting;
using WindowsSevicerTest;
using DatabaseInsertAndExportLibrary;
using DatabaseInsertAndExportLibrary.HKEXDatabaseDataSetTableAdapters;

namespace WindowsFormsApplication
{
    public partial class AutoForm : Form
    {
        //private BindingSource bindingSource1 = new BindingSource();

        public AutoForm()
        {
            InitializeComponent();
        }

        private void buttonget_Click(object sender, EventArgs e)
        {
            DateTime today = dateTimePicker1.Value;
            //Implement the database export to data grid view
        }

        private void AddComboBoxControl(ComboBox comboBoxaxis)
        {
            for (int i = 0; i < dataGridView1.ColumnCount; i++)
            {
                comboBoxaxis.Items.Add(dataGridView1.Columns[i].Name);
            }
        }

        private void AutoForm_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'hKEXDatabaseDataSet.StockOptionsContract' table. You can move, or remove it, as needed.
            this.stockOptionsContractTableAdapter.Fill(this.hKEXDatabaseDataSet.StockOptionsContract);
            toolStripTextBox1.Text = Properties.Settings.Default.email;
          
        }


        private void exportToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog fbd = new FolderBrowserDialog();
            this.chart1.SaveImage(fbd.SelectedPath + "chart.png", ChartImageFormat.Png);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            GraphPlotter gp = new GraphPlotter(chart1, dataGridView1, comboBoxXaxis, comboBoxYaxis);
            gp.graphPlot();
        }

        private void comboBoxYaxis_DropDown(object sender, EventArgs e)
        {
            comboBoxYaxis.Items.Clear();
            AddComboBoxControl(comboBoxYaxis);
        }

        private void comboBoxXaxis_DropDown(object sender, EventArgs e)
        {
            comboBoxXaxis.Items.Clear();
            AddComboBoxControl(comboBoxXaxis);
        }

        private void aboutToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Auto Capture System");
        }

        private void toolStripTextBox1_TextChanged(object sender, EventArgs e)
        {
            Properties.Settings.Default.email = toolStripTextBox1.Text;
        }

        private void hSIF1ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            labelCurrentStockType.Text = "HSIF1";
            HKEXDatabaseDataSet.HangSengIndexFutures1DataTable dt = this.hKEXDatabaseDataSet.HangSengIndexFutures1;
            dataGridView1.DataSource = dt;
            // TODO: This line of code loads data into the 'hKEXDatabaseDataSet.HangSengIndexFutures1' table. You can move, or remove it, as needed.
            this.hangSengIndexFutures1TableAdapter.Fill(this.hKEXDatabaseDataSet.HangSengIndexFutures1);
           
        }

        private void hSIF2ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            labelCurrentStockType.Text = "HSIF2";
            HKEXDatabaseDataSet.HangSengIndexFutures2DataTable dt = this.hKEXDatabaseDataSet.HangSengIndexFutures2;
            dataGridView1.DataSource = dt;
            // TODO: This line of code loads data into the 'hKEXDatabaseDataSet.HangSengIndexFutures2' table. You can move, or remove it, as needed.
            this.hangSengIndexFutures2TableAdapter.Fill(this.hKEXDatabaseDataSet.HangSengIndexFutures2);
            
        }

        private void hSIOToolStripMenuItem_Click(object sender, EventArgs e)
        {
            labelCurrentStockType.Text = "HSIO";
            HKEXDatabaseDataSet.HangSengIndexOptionsDataTable dt = this.hKEXDatabaseDataSet.HangSengIndexOptions;
            dataGridView1.DataSource = dt;
            // TODO: This line of code loads data into the 'hKEXDatabaseDataSet.HangSengIndexOptions' table. You can move, or remove it, as needed.
            this.hangSengIndexOptionsTableAdapter.Fill(this.hKEXDatabaseDataSet.HangSengIndexOptions);
            
        }

        private void hHIF1ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            labelCurrentStockType.Text = "HHIF1";
            HKEXDatabaseDataSet.HsharesIndexFutures1DataTable dt = this.hKEXDatabaseDataSet.HsharesIndexFutures1;
            dataGridView1.DataSource = dt;
            // TODO: This line of code loads data into the 'hKEXDatabaseDataSet.HsharesIndexFutures1' table. You can move, or remove it, as needed.
            this.hsharesIndexFutures1TableAdapter.Fill(this.hKEXDatabaseDataSet.HsharesIndexFutures1);
            
        }

        private void hHIF2ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            labelCurrentStockType.Text = "HHIF2";
            HKEXDatabaseDataSet.HsharesIndexFutures2DataTable dt = this.hKEXDatabaseDataSet.HsharesIndexFutures2;
            dataGridView1.DataSource = dt;
            // TODO: This line of code loads data into the 'hKEXDatabaseDataSet.HsharesIndexFutures1' table. You can move, or remove it, as needed.
            this.hsharesIndexFutures2TableAdapter.Fill(this.hKEXDatabaseDataSet.HsharesIndexFutures2);
        }

        private void dQEToolStripMenuItem_Click(object sender, EventArgs e)
        {
            labelCurrentStockType.Text = "DQE";
            HKEXDatabaseDataSet.StockOptionsContractDataTable dt = this.hKEXDatabaseDataSet.StockOptionsContract;
            dataGridView1.DataSource = dt;
            // TODO: This line of code loads data into the 'hKEXDatabaseDataSet.StockOptionsStockname' table. You can move, or remove it, as needed.
            this.stockOptionsContractTableAdapter.Fill(this.hKEXDatabaseDataSet.StockOptionsContract);
            
        }

        private void ClearDataInDataGridView()
        {
            dataGridView1.Columns.Clear();
        }

        private void callPutTestingToolStripMenuItem_Click(object sender, EventArgs e)
        {
            
            
            HKEXDatabaseDataSet.CallPutIdDataTable dt = this.hKEXDatabaseDataSet.CallPutId;
            dataGridView1.DataSource = dt;
            // TODO: This line of code loads data into the 'hKEXDatabaseDataSet.CallPutId' table. You can move, or remove it, as needed.
            this.callPutIdTableAdapter.Fill(this.hKEXDatabaseDataSet.CallPutId);
        }

    

    }

}
